package net.m510.autosurfer.nifty;

import java.net.URI;
import java.util.logging.Logger;

import net.m510.autosurfer.common.DocumentGetProcess;
import net.m510.autosurfer.core.DocumentChecker;
import net.m510.autosurfer.core.exception.UserProcessException;
import net.m510.autosurfer.core.utils.DocumentCheckUtils;

import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.CloseableHttpClient;
import org.jsoup.nodes.Document;

public final class NiftyLogout extends DocumentGetProcess implements DocumentChecker {
	private static final Logger log = Logger.getLogger(NiftyLogout.class.getName());

	public NiftyLogout() {
		this(null,null);
	}
	public NiftyLogout(CloseableHttpClient client,HttpClientContext context) {
		super(client, context);
		super.log = log;
	}

	@Override
	public void check(Document doc) throws UserProcessException {
		DocumentCheckUtils.checkTitleContainsText(doc, "ログアウト");
	}
	@Override
	protected URI getUri(Document doc) {
		return URI.create("https://sso.nifty.com/pub/logout.cgi?service=sptweb05");
	}
	@Override
	protected RequestConfig getCustomRequestConfig() {
		return RequestConfig.custom().setCookieSpec(CookieSpecs.IGNORE_COOKIES).build();
	}
}
